#include "stdafx.h"
#include "BoardCell.h"


BoardCell::BoardCell(void)
{
}


BoardCell::~BoardCell(void)
{
	imagePointer.Free();
	free(imagePointer);
}

GdiplusImagePtr* imagePointer = (GdiplusImagePtr*) malloc(sizeof(GdiplusImagePtr)+1);

void BoardCell::SetImage(std::string fileDir)
{
	wchar_t* wFileDir = ConvertToWcharT(fileDir);
	imagePointer.Attach(new Gdiplus::Image(wFileDir));
}

void BoardCell::SetXPosition(int x)
{
	drawPosition.x = x;
}

int BoardCell::GetXPosition()
{
	return drawPosition.x;
}

void BoardCell::SetYPosition(int y)
{
	drawPosition.y = y;
}

int BoardCell::GetYPosition()
{
	return drawPosition.y;
}

void BoardCell::Draw(Gdiplus::Graphics &graphics)
{
	graphics.DrawImage(imagePointer, drawPosition.x, drawPosition.y);
}

wchar_t * BoardCell::ConvertToWcharT(std::string inputString)
{
	wchar_t* wChars = new wchar_t[inputString.length() + 1];
	for(int i =0; i< (int)inputString.length(); i++)
	{
		wChars[i] = inputString[i];
	}
	wChars[inputString.length()] = 0;
	return wChars;
}